package appx.craft.droid.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import appx.craft.droid.R;
import appx.craft.droid.utils.Constance;
import appx.craft.droid.utils.UtilityHelper;

public class PreviewImagesActivity  extends Activity{
	
	private String imagePath;
	private ImageView imageView_preview;
	private Button btn_pick_again, btn_done;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_preview_images);
		imagePath = getIntent().getStringExtra(Constance.INTENT_KEY_IMAGE_PATH);
		if (!imagePath.equals("")) {
			Toast.makeText(getApplicationContext(), imagePath,
					Toast.LENGTH_LONG).show();
		}
		
		imageView_preview = (ImageView) findViewById(R.id.imageView_preview);
		imageView_preview.post(new Runnable() {

			@Override
			public void run() {
				imageView_preview.setImageBitmap(UtilityHelper.decodeSampledBitmapFromResource(imagePath,480,480));
			}
		});
		
		btn_done = (Button)findViewById(R.id.btn_done);
		btn_done.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				Intent mShareIntent = new Intent(PreviewImagesActivity.this,SharePhotoCaptureActivity.class);
				mShareIntent.putExtra(Constance.INTENT_KEY_IMAGE_PATH,imagePath);
				mShareIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
				startActivity(mShareIntent);
				finish();
			}
		});
		
		btn_pick_again = (Button)findViewById(R.id.btn_pick_again);
		btn_pick_again.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
	}
	
	@Override
	protected void onStart() {
		super.onStart();
	}
	
	@Override
	protected void onStop() {
		super.onStop();
	}
	
	@Override
	protected void onResume() {
		super.onResume();
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
	}
	
}
